﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THenu.TinyHourseLib.DesignPattern.Structural_Patterns.Bridge_Pattern
{
    public class BridgePattern :IPatternDemonstrate
    {
        public void StructuralCode()
        {
            Abstraction abs = new RefinedAbstraction();

            // Set implementation and call
            abs.Implementor = new ConcreteImplementorA();
            abs.Operation();

            // Change implementation and call
            abs.Implementor = new ConcreteImplementorB();
            abs.Operation();
        }

        public string PatternDescription()
        {
            string description = @"
Definition
Decouple an abstraction from its implementation so that the two can vary independently.

Participants

    The classes and objects participating in this pattern are:

Abstraction   (BusinessObject)
defines the abstraction's interface.
maintains a reference to an object of type Implementor.
RefinedAbstraction   (CustomersBusinessObject)
extends the interface defined by Abstraction.
Implementor   (DataObject)
defines the interface for implementation classes. This interface doesn't have to correspond exactly to Abstraction's interface; in fact the two interfaces can be quite different. Typically the Implementation interface provides only primitive operations, and Abstraction defines higher-level operations based on these primitives.
ConcreteImplementor   (CustomersDataObject)
implements the Implementor interface and defines its concrete implementation.";
            return description;


        }

        public void RealWorldExample()
        {
            Customers customers = new Customers("Chicago");

            customers.Data = new CustomersData();

            customers.Show();
            customers.Next();
            customers.Show();
            customers.Next();
            customers.Show();
            customers.Add("Henry Velasquez");

            customers.ShowAll();
 
        }
    }
}
